<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.lable.CaiGouSheZhi"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <style type="text/css">
    	.configDiv {
    		margin-top: 5px !important;
    		margin-bottom: 5px !important;
    		padding-top: 7px !important;
    		padding-bottom: 7px !important;
    		border-bottom: 1px solid #f4f4f4;
    	}
    </style>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>区域配送企业数设置</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.CaiGouSheZhi"/></a></li>
        </ol>
    </section>
    <section class="content">
	<form id="form" class="form-horizontal" action="savePurConfigList.html" method="post">
	    <div class="box box-success">
	    <div style="position: absolute;bottom:45px;right:10px;"><img src='${ctx}/lib/img/PurConfig.png'></div>
					<div style="width:100%;height:70px;"></div>
				      <div class="form-group form-group-xs" style="margin-left: 15px;width: 720px;">
                        <label for="newpassword" class="col-sm-10 text-right"><strong style="font-size: 17px;">每县区基层医疗机构最大配送企业数</strong></label>
                        <div class="col-sm-1 text-left">
                        <strong style="color:red">${map.max_delnum_base}</strong>
                        </div>
                     </div>
                     <div class="form-group form-group-xs" style="margin-left: 15px;width: 720px;">
                        <label for="newpassword" class="col-sm-10 text-right"><strong style="font-size: 17px;">每县区县及县以上的医疗机构最大配送企业数</strong></label>
                        <div class="col-sm-1 text-left">
                        <strong style="color:red">${map.max_delnum_county}</strong>
                        </div>
                    </div>  
        </div>
	</form>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
    function saveConfig() {
        	if(!validata()){
        	   return;
        	} 
          $.HN.message.confirm("确定保存设置吗？", '', '').on(function (e) {
	            if (e) {
			          $.post("${ctx}/purConfig/setupEveryAreaDel.html", {
			        	   "baseDelNum":$("#baseDelNum").val(),"countyDelNum":$("#countyDelNum").val()
			          }, function(result) {
			        	  if (result.success) {
			                  top.$.alert("<spring:message code="message.HN.alert.BaoCunsuccess"/>", "success");
			                  document.location="${ctx}/purConfig/toSetupAreaDel.html";
			              } else {
			                  top.$.alert("<spring:message code="message.HN.alert.BaoCunFail"/>", "error");
			              }
			          }, "json");
	            }
			}); 
        }
    function validata(){
    	var baseDelNum =$("#baseDelNum").val();
    	if((/[^0-9]{1,}/.test(baseDelNum))){
    		top.$.alert("数字须是正整数");
			$("#baseDelNum").focus();
			return false;
		}
		if(baseDelNum>99){
			top.$.alert("数字不能超过99");
			$("#baseDelNum").focus();
			return false;
		}
		
    	var countyDelNum =$("#countyDelNum").val();
     	if((/[^0-9]{1,}/.test(countyDelNum))){
     		top.$.alert("数字须是正整数");
			$("#countyDelNum").focus();
			return false;
		}
		if(countyDelNum>99){
			top.$.alert("数字不能超过99");
			$("#countyDelNum").focus();
			return false;
		}
		 return true;
    		/* var i=0;
    		var temp =false;
    		$(".form-control").each(function(){
    			var num= $(this).val();
    			if((/[^0-9]{1,}/.test(num))){
        			alert("数字须是正整数");
        			$(this).focus();
        			temp= false;
        		}
        		if(num>99){
        			alert("数字不能超过99");
        			$(this).focus();
        			temp = false;
        		}
        		console.log(i);
        		if(i==1){temp = true;}
        		i++;
    		});
   			 return temp; */
       }
    </script>
</body>
</html>
